<?php

namespace api\ygzc\controller;

use think\facade\Db;
use think\facade\Validate;
use api\ygzc\model\WxPushModel;
use cmf\controller\RestBaseController;

class WxPushController extends RestBaseController
{
    
	public function wx_push(){
		
		$param = $this->request->param();

		$is_find_user = Db::name('third_party_merchant')->where(['merchant_id'=>$param['merchant_id'],'domain'=>$param['domain']])->find();
		if($is_find_user){
			$WxPushModel = new WxPushModel();
			$res = $WxPushModel->tsmbmsg($is_find_user['openid'],$param['order_sn']);
			$res = json_decode($res,true);
		}else{
			$res['errcode'] = '10001';
			$res['errmsg'] = '暂未绑定微信公众号';
		}
		if($res['errcode'] == 0 && $res['errmsg'] == 'ok'){
			$this->success('推送成功');
		}else{
			$this->error($res['errmsg']);
		}
	}
	

}
